        

        var intangibleStore = new Ext.data.JsonStore({
			url: '/weihe/getSelf_harvest',
			root: 'datas',
			fields : [{
						name:'IntangibleId',mapping:'id'
					},{
     				   name:'IntangibleDate', mapping:'date',type : 'date', dateFormat:"Y-m-d"
      			  	},{
						name:'IntangibleType',mapping:'type'
					},{
						name:'IntangibleLocation',mapping:'location'
					},{
						name:'IntangibleSort',mapping:'sort'
					},{
						name:'IntangibleBalance',mapping:'balance'
				    },{
				    	name:'IntangibleYearLimit',mapping:'yearLimit'
				    },{
				    	name:'IntangibleArea',mapping:'area'
				    },{
				    	name:'IntangiblePrimiary',mapping:'primary'
				    },{
				    	name:'IntangibleCurrent',mapping:'current'
				    }]
		});
        
        
   
    	

intangibles = function(){
  return{
     
	
	 intangibleGrid : function(){

		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
	    var pageToolBar = new Ext.PagingToolbar({
			pageSize : 15,
			store : intangibleStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
			});
		 
	   var intangibleGrid = new Ext.grid.GridPanel({
		   id:'intangibleGrid',
		   title : '自营成果表',
		   region : 'center',
		   height :300,
		   minColumnWidth : 50,
		   tbar:["-",'新增记录:',new Ext.form.TextField({id:'ym',name:'query',value:(new Date()).format('Y-m'),width:'60',regex : /^\d{4}-(?:0[1-9]|1[0-2])$/,
		    regexText:'请输入有效日期格式为2010-01' }),new Ext.Button({text:'提交',handler : function() {
			   					progressConsole();
								Ext.Ajax.request({
									url : '/weihe/addSelf_harvest',
									success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.success) {
										Ext.Msg.alert('消息', json.msg, function() {
													Ext.getCmp("intangibleGrid").getStore().baseParams = {'query':Ext.getCmp('ym').getValue()};
			   										Ext.getCmp("intangibleGrid").getStore().load({params : {start : 0, limit : 12}});
									});
									}else{
											Ext.Msg.alert('消息', json.msg);
									}
									},
									failure : function() {
										Ext.Msg.alert('错误', '删除失败!');
									},
									params : 'sd=' + Ext.getCmp('ym').getValue()
								});
			   		
		   		}})
		   ,"-",'查看年份:',new Ext.form.TextField({id:'year',name:'query',value:(new Date()).format('Y'),width:'50'}),new Ext.Button({text:'提交',handler : function() {
			   					Ext.getCmp("intangibleGrid").getStore().baseParams = {'query':Ext.getCmp('year').getValue()};
			   					Ext.getCmp("intangibleGrid").getStore().load({params : {start : 0, limit : 12}});
		   		}})
		   ,"-"],

		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   store : intangibleStore,
		   columns: [
		             {header : '日期', dataIndex : 'IntangibleDate', menuDisabled : true,renderer:function(value, cellmeta, record, rowIndex){
							if(value != null&&(rowIndex%6==0)){
									return value.format('Y年m月');
								}else if (value != null&&((rowIndex+1)%6==0)){
									return '本月合计';
								}else if(value == null){
									return '本年累计';
								}else{
									return "";
								}
		             }},
		             {header : '类别', dataIndex : 'IntangibleType'},
		             {header : '所在地', dataIndex : 'IntangibleLocation'},
		             {header : '本月增、减', dataIndex : 'IntangibleBalance'},
		             {header : '种类', dataIndex : 'IntangibleSort'},
		             {header : '使用权年限', dataIndex : 'IntangibleYearLimit'},
		             {header : '面积', dataIndex : 'IntangibleArea'},
		             {header : '购入原值', dataIndex : 'IntangiblePrimiary'},
		             {header : '现值', dataIndex : 'IntangibleCurrent'}
        ],
           sm : rowSelectionModel,
           listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   var record = grid.getStore().getAt(rowIndex);
			   if(record.get('IntangibleType')!=""){
			   	  Ext.getCmp("intangibleForm").form.loadRecord(record);
			  	  var d = record.get('IntangibleDate').format('Y-m')+"";
			  	  Ext.getCmp("intangibleForm").form.findField('sd').setValue(d);
			   	}
			   	else{
			   		 Ext.getCmp("intangibleForm").form.reset();
			   		Ext.Msg.alert('提示','不能修改合计数据!');
			   	}
			   	
			   }
		   
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return intangibleGrid;
	},
	intangibleForm : function(){
		var button_add = new Ext.Button({
			text : '添加/修改',
			handler : function() {
					progressConsole();
				if(intangibleForm.form.isValid()){ 	
						intangibleForm.form.submit({
						  url : '/weihe/updateSelf_harvest',
						   success : function(form, action) {
							 if (action.result.success) {
								Ext.Msg.alert('消息', action.result.msg, function() {
									   intangibleForm.form.reset();
									   Ext.getCmp("intangibleGrid").getStore().reload();
								});
							  }
						    }
					    });
				}else{
					Ext.Msg.alert('提示','请输入相关内容');
				}
					}
		});

	var button_clear = new Ext.Button({
		id : 'button_clear',
		text : '清空',
		handler : function() {
			intangibleForm.form.reset();
			intangibleForm.buttons[0].setText('添加');
		}
	});


	var  intangibleForm = new Ext.form.FormPanel({
		id : 'intangibleForm',
		title : '自营业务信息',
		frame : true,
		width : 300,
		region : 'east',
		autoScroll : true,
		labelAlign : 'right',
		labelWidth : 60,
		defaultType : 'textfield',
			defaults : {
			width : 200
		},
		items : [{  
			id:'IntangibleId',
			xtype : 'hidden',  
			name : 'intangible.id'
		},{
			id:'IntangibleDate',
			fieldLabel : '日期',
			name : 'sd',
			readOnly : true
		},{
			  id : 'IntangibleType',
			  fieldLabel : '类别',
		      name : 'intangible.type',
			  readOnly : true
		   },{
			id:'IntangibleLocation',
			fieldLabel : '所在地',
			name : 'intangible.location'
		},{
			id:'IntangibleBalance',
			fieldLabel : '本月增减',
			name : 'intangible.balance',
			regex : /^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'IntangibleSort',
			fieldLabel : '费用',
			name : 'intangible.fee',
			regex : /^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'IntangibleYearLimit',
			fieldLabel : '使用权年限',
			name : 'intangible.yearLimit',
			regex : /^\d+(\.\d+)?$/,
		    regexText:'请输入有效的年限' 
		},{
			id:'IntangibleArea',
			fieldLabel : '面积',
			name : 'intangible.area',
			regex : /^-?\d+(\.\d+)?$/,
		    regexText:'请输入有效的面积' 
		},{
			id:'IntangiblePrimiary',
			fieldLabel : '购入原值',
			name : 'intangible.primiary',
			regex : /^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'IntangibleCurrent',
			fieldLabel : '现值',
			name : 'intangible.current',
			regex : /^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		}],
		buttons : [button_add,button_clear]
	});
		return  intangibleForm;
	}
  }
}();








